	.file	"main.c"
	.intel_syntax noprefix
 # GNU C17 (x86_64-win32-seh-rev0, Built by MinGW-W64 project) version 8.1.0 (x86_64-w64-mingw32)
 #	compiled by GNU C version 8.1.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.18-GMP

 # GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 # options passed:  -imultilib .
 # -iprefix D:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/
 # -U_REENTRANT main.c -m32 -masm=intel -mtune=core2 -march=nocona
 # -fverbose-asm
 # options enabled:  -faggressive-loop-optimizations
 # -fasynchronous-unwind-tables -fauto-inc-dec -fchkp-check-incomplete-type
 # -fchkp-check-read -fchkp-check-write -fchkp-instrument-calls
 # -fchkp-narrow-bounds -fchkp-optimize -fchkp-store-bounds
 # -fchkp-use-static-bounds -fchkp-use-static-const-bounds
 # -fchkp-use-wrappers -fcommon -fdelete-null-pointer-checks
 # -fdwarf2-cfi-asm -fearly-inlining -feliminate-unused-debug-types
 # -ffp-int-builtin-inexact -ffunction-cse -fgcse-lm -fgnu-runtime
 # -fgnu-unique -fident -finline-atomics -fira-hoist-pressure
 # -fira-share-save-slots -fira-share-spill-slots -fivopts
 # -fkeep-inline-dllexport -fkeep-static-consts -fleading-underscore
 # -flifetime-dse -flto-odr-type-merging -fmath-errno -fmerge-debug-strings
 # -fpeephole -fplt -fprefetch-loop-arrays -freg-struct-return
 # -fsched-critical-path-heuristic -fsched-dep-count-heuristic
 # -fsched-group-heuristic -fsched-interblock -fsched-last-insn-heuristic
 # -fsched-rank-heuristic -fsched-spec -fsched-spec-insn-heuristic
 # -fsched-stalled-insns-dep -fschedule-fusion -fsemantic-interposition
 # -fset-stack-executable -fshow-column -fshrink-wrap-separate
 # -fsigned-zeros -fsplit-ivs-in-unroller -fssa-backprop -fstdarg-opt
 # -fstrict-volatile-bitfields -fsync-libcalls -ftrapping-math
 # -ftree-cselim -ftree-forwprop -ftree-loop-if-convert -ftree-loop-im
 # -ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops=
 # -ftree-phiprop -ftree-reassoc -ftree-scev-cprop -funit-at-a-time
 # -funwind-tables -fverbose-asm -fzero-initialized-in-bss -m32 -m80387
 # -m96bit-long-double -maccumulate-outgoing-args -malign-double
 # -malign-stringops -mcx16 -mfancy-math-387 -mfp-ret-in-387 -mfxsr
 # -mieee-fp -mlong-double-80 -mmmx -mms-bitfields -mno-red-zone -mno-sse4
 # -mpush-args -msahf -msse -msse2 -msse3 -mstack-arg-probe -mstackrealign
 # -mvzeroupper

	.text
	.globl	_add
	.def	_add;	.scl	2;	.type	32;	.endef
# add函数的入口
_add:
    # 把原有函数即main函数的栈基指针压栈，压栈是把ebp的值保存到内存上，位置就是esp指向的位置
	push	ebp	 #
	# 把main的栈顶指针esp作为add函数的栈基指针ebp
	mov	ebp, esp	 #,
	# 由于add函数自身需要使用栈空间，把esp减去16是指add函数的栈空间大小是16个字节
	sub	esp, 16	 #,
 # main.c:4:     ret = a + b;
    # 拿到实参a的值，并放入寄存器edx中
	mov	edx, DWORD PTR [ebp+8]	 # tmp93, a
	# 拿到实参b的值，并放入寄存器eax中
	mov	eax, DWORD PTR [ebp+12]	 # tmp94, b
	# 将edx的值和eax的值相加，并存放到eax中
	add	eax, edx	 # tmp92, tmp93
	# 将eax的值存放到栈基指针向下偏移4个字节的位置
	mov	DWORD PTR [ebp-4], eax	 # ret, tmp92
 # main.c:5:     return ret;
    # 将栈基指针向下偏移4个字节的值存放到eax中
	mov	eax, DWORD PTR [ebp-4]	 # _4, ret
 # main.c:6: }
	leave
	# 函数返回，弹出压栈的指令返回地址，回到main函数执行
	ret	
	.def	___main;	.scl	2;	.type	32;	.endef
	.section .rdata,"dr"
LC0:
	.ascii "add result = %d\12\0"
	.text
	.globl	_main
	.def	_main;	.scl	2;	.type	32;	.endef
_main:
	push	ebp	 #
	mov	ebp, esp	 #,
	and	esp, -16	 #,
	sub	esp, 32	 #,
 # main.c:7: int main() {
    # 调用main函数
	call	___main	 #
 # main.c:10:     a = 5;
    # 将常量5放入栈指针esp偏移16个字节的位置，该位置是变量a的空间
	mov	DWORD PTR [esp+16], 5	 # a,
 # main.c:11:     p = &a;
    # 将esp+16位置的地址放入到eax寄存器中
	lea	eax, [esp+16]	 # tmp91,
	# 将eax中的值放到栈指针偏移28个字节的位置，即指针变量p中
	mov	DWORD PTR [esp+28], eax	 # p, tmp91
 # main.c:12:     b = *p +2;
    # 将栈指针偏移28个字节的位置，即指针变量p的值存放到eax寄存器中
	mov	eax, DWORD PTR [esp+28]	 # tmp92, p
	# 把eax寄存器中的值作为地址去内存访问到对应的数据，放入eax中
	mov	eax, DWORD PTR [eax]	 # _1, *p_5
 # main.c:12:     b = *p +2;
    # 将eax中的值+2存放到eax中
	add	eax, 2	 # tmp93,
	# 将eax的值放到栈指针偏移24个字节的位置，即变量b中
	mov	DWORD PTR [esp+24], eax	 # b, tmp93
 # main.c:13:     ret = add(a,b);
    # 将变量a的值放到eax寄存器中
	mov	eax, DWORD PTR [esp+16]	 # a.0_2, a
	# 将变量b的值放到edx寄存器中
	mov	edx, DWORD PTR [esp+24]	 # tmp94, b
	# 将edx中的值(变量b)放到自己的栈指针偏移4的内存位置
	mov	DWORD PTR [esp+4], edx	 #, tmp94
	# 将eax中的值(变量a)放到自己的栈指针的内存位置
	mov	DWORD PTR [esp], eax	 #, a.0_2
	# 调用add函数
	call	_add	 #
	mov	DWORD PTR [esp+20], eax	 # ret, tmp95
 # main.c:14:     printf("add result = %d\n",ret);
	mov	eax, DWORD PTR [esp+20]	 # tmp96, ret
	mov	DWORD PTR [esp+4], eax	 #, tmp96
	mov	DWORD PTR [esp], OFFSET FLAT:LC0	 #,
	call	_printf	 #
 # main.c:15:     return 0;
	mov	eax, 0	 # _10,
 # main.c:16: }
	leave	
	ret	
	.ident	"GCC: (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0"
	.def	_printf;	.scl	2;	.type	32;	.endef
